import request from "@/utils/request";
import crypto from "@/utils/secret";

export function login(data) {
  const {username, password} = data;
  const body = {
    type: "normal",
    identifier: username,
    credential: crypto.encrypt(password)
  };
  return request({
    url: "/auth/signIn",
    method: "post",
    data: body
  });
}

export function logout() {
  return request({
    url: "/auth/logout",
    method: "post"
  });
}

export function getInfo(token) {
  return request({
    url: "/my/info",
    method: "get",
    params: { token }
  });
}

export function getUser(id) {
  return request({
    url: "/user/"+ id,
    method: "get"
  });
}


